package com.bj.jiufu.util.redis;

import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.apache.log4j.Logger;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisHashUtil{
	/** 日志实例 */
	private static final Logger logger = Logger.getLogger(RedisHashUtil.class);
	
	private static JedisPool jedisPool = RedisPoll.getInstance();

	public static void hasPut(String key,HashMap<String,String> value) {  
		Jedis jedis = null;
		try {
			if (jedisPool == null)
				jedisPool = RedisPoll.getInstance();
			jedis = jedisPool.getResource();
			
			jedis.hmset(key, value);
			
		} catch (Exception e) {
			logger.error(e);
		} finally {
			if (null != jedis) {
				jedis.close();
			}
		}
	}
	
	public static List<String> hasGet(String key,String member) {  
		Jedis jedis = null;
		List<String> value =null;
		try {
			if (jedisPool == null)
				jedisPool = RedisPoll.getInstance();
			jedis = jedisPool.getResource();

			value = jedis.hmget(key, member);
			
		} catch (Exception e) {
			logger.error(e);
		} finally {
			if (null != jedis) {
				jedis.close();
			}
		}
		return value;
	}
	
	public static Long hasDel(String key,String member) {  
		Jedis jedis = null;
		Long value =null;
		try {
			if (jedisPool == null)
				jedisPool = RedisPoll.getInstance();
			jedis = jedisPool.getResource();
			
			value = jedis.hdel(key, member);
		} catch (Exception e) {
			logger.error(e);
		} finally {
			if (null != jedis) {
				jedis.close();
			}
		}
		return value;
	}
}
